package com.lh.threadtest.t14;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;


/***
 * 
* @ClassName: CollectionTest 
* @Description: TODO
* @author Liu
* @date 2018年1月18日 下午8:44:27 
*
 */
public class CollectionTest {
	public static void main(String[] args) {
		Collections.synchronizedMap(null);
		
//		Collection users = new ArrayList();
		Collection users = new CopyOnWriteArrayList();
		users.add(new User("张三", 28));
		users.add(new User("李四", 25));
		users.add(new User("王五", 31));
		Iterator itrUsers = users.iterator();
		while (itrUsers.hasNext()) {
			User user = (User) itrUsers.next();
			if ("张三".equals(user.getName())) {
				users.remove(user);
				// itrUsers.remove();
			} else {
				System.out.println(user);
			}
		}
	}
}
